package main
import (
	"encoding/json"
	"fmt"
)
type DebugInfo struct {
	Level string `json:"level"` // 按规则解析字段
	Msg string
	Age int `json:"age,omitempty,string"` // omitempty: 0和空不解析 type: 改变类型
	author string // 小写不转换（私有变量）
}

func main() {
	dbgInfs := []DebugInfo {
		DebugInfo{"debug", `File: "text.txt" Not Found`, 18, "Cynhard"},
		DebugInfo{"", "Logic error", 0, "Gopher"},
	}
	if data, err := json.MarshalIndent(dbgInfs, "", " "); err == nil {
		fmt.Printf("%s\n", data)
	}
}